home *** CD-ROM | disk | FTP | other *** search
/ CGI How-To / CGI HOW-TO.iso / chap2 / 2_6 / chkaddr.txt < prev   
Encoding:
Text File  |  1996-06-15  |  829 b   |  41 lines

  1. #!/usr/bin/perl
  2.  
  3. # Send the output mime type to the server to know what output to handle.
  4.  
  5. print "Content-type: text/html\n\n";
  6.  
  7. # Print HTML header information.
  8.  
  9. print <<EOH;
  10. <HTML>
  11. <HEAD><TITLE>CGI Script How-to: Test Script</TITLE></HEAD>
  12. <BODY>
  13. <H1>CGI Script How-to<BR>determine the client machine's name</H1>
  14. EOH
  15.  
  16. # Access the environment variable by name
  17.  
  18. $remote_addr = $ENV{'REMOTE_ADDR'};
  19.  
  20. # Send the mime type to the server to know what output to handle.
  21.  
  22. # Test and use the variable. If the value is not defined then the server
  23. # could not identify the client who will remain anonymous.
  24.  
  25. if ($remote_addr)
  26. {
  27.     print "Your Internet address is <B>$remote_addr</B>\n";
  28. }
  29. else
  30. {
  31.     print "I don't know your Internet address. Who are you?\n";
  32. }
  33.  
  34. # Print closing HTML tags.
  35.  
  36. print "</BODY></HTML>\n";
  37.  
  38. #
  39. # end of chkaddr.pl
  40. #
  41.